]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add finer-grained signals to ShellAppMonitor, update appDisplay
authorDan Winship <danw@gnome.org>
Wed, 12 Aug 2009 20:05:25 +0000 (16:05 -0400)
committerDan Winship <danw@gnome.org>
Wed, 12 Aug 2009 21:08:19 +0000 (17:08 -0400)
js/ui/appDisplay.js
src/shell-app-monitor.c
src/shell-app-monitor.h
src/shell-marshal.list

index 7d28fbaff0e210acc4b65e82a873a5a714e6968c..57d3608cc2ed7cbe3e298088a7e056973af02131 100644 (file)
@@ -193,7 +193,10 @@ AppDisplay.prototype = {
         this._appSystem.connect('favorites-changed', Lang.bind(this, function(appSys) {
             this._redisplay(false);
         }));
-        this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
+        this._appMonitor.connect('app-added', Lang.bind(this, function(monitor) {
+            this._redisplay(false);
+        }));
+        this._appMonitor.connect('app-removed', Lang.bind(this, function(monitor) {
             this._redisplay(false);
         }));
 
@@ -761,7 +764,10 @@ AppWell.prototype = {
         this._appSystem.connect('favorites-changed', Lang.bind(this, function(appSys) {
             this._redisplay();
         }));
-        this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
+        this._appMonitor.connect('app-added', Lang.bind(this, function(monitor) {
+            this._redisplay();
+        }));
+        this._appMonitor.connect('app-removed', Lang.bind(this, function(monitor) {
             this._redisplay();
         }));
 
index 0a9e80f20e7ff06fb82b84c6418f98560cd0172c..ebeba0e9cca5dd60355f380d7aaa42b6213e072d 100644 (file)
@@ -18,6 +18,7 @@
 #include "shell-app-monitor.h"
 #include "shell-app-system.h"
 #include "shell-global.h"
+#include "shell-marshal.h"
 
 #include "display.h"
 #include "window.h"
@@ -154,7 +155,10 @@ struct AppUsage
 };
 
 enum {
-  CHANGED,
+  APP_ADDED,
+  APP_REMOVED,
+  WINDOW_ADDED,
+  WINDOW_REMOVED,
   STARTUP_SEQUENCE_CHANGED,
 
   LAST_SIGNAL
@@ -196,13 +200,41 @@ static void shell_app_monitor_class_init(ShellAppMonitorClass *klass)
 
   gobject_class->finalize = shell_app_monitor_finalize;
 
-  signals[CHANGED] = g_signal_new ("changed",
-                                   SHELL_TYPE_APP_MONITOR,
-                                   G_SIGNAL_RUN_LAST,
-                                   0,
-                                   NULL, NULL,
-                                   g_cclosure_marshal_VOID__VOID,
-                                   G_TYPE_NONE, 0);
+  signals[APP_ADDED] = g_signal_new ("app-added",
+                                     SHELL_TYPE_APP_MONITOR,
+                                     G_SIGNAL_RUN_LAST,
+                                     0,
+                                     NULL, NULL,
+                                     _shell_marshal_VOID__BOXED,
+                                     G_TYPE_NONE, 1,
+                                     SHELL_TYPE_APP_INFO);
+  signals[APP_REMOVED] = g_signal_new ("app-removed",
+                                       SHELL_TYPE_APP_MONITOR,
+                                       G_SIGNAL_RUN_LAST,
+                                       0,
+                                       NULL, NULL,
+                                       _shell_marshal_VOID__BOXED,
+                                       G_TYPE_NONE, 1,
+                                       SHELL_TYPE_APP_INFO);
+
+  signals[WINDOW_ADDED] = g_signal_new ("window-added",
+                                        SHELL_TYPE_APP_MONITOR,
+                                        G_SIGNAL_RUN_LAST,
+                                        0,
+                                        NULL, NULL,
+                                        _shell_marshal_VOID__BOXED_OBJECT,
+                                        G_TYPE_NONE, 2,
+                                        SHELL_TYPE_APP_INFO,
+                                        META_TYPE_WINDOW);
+  signals[WINDOW_REMOVED] = g_signal_new ("window-removed",
+                                          SHELL_TYPE_APP_MONITOR,
+                                          G_SIGNAL_RUN_LAST,
+                                          0,
+                                          NULL, NULL,
+                                          _shell_marshal_VOID__BOXED_OBJECT,
+                                          G_TYPE_NONE, 2,
+                                          SHELL_TYPE_APP_INFO,
+                                          META_TYPE_WINDOW);
 
   signals[STARTUP_SEQUENCE_CHANGED] = g_signal_new ("startup-sequence-changed",
                                    SHELL_TYPE_APP_MONITOR,
@@ -526,15 +558,18 @@ track_window (ShellAppMonitor *self,
 
   usage = get_app_usage_from_window (self, window);
 
-  /* Ephemerally keep track of the number of windows open for this app,
-   * when it switches between 0 and 1 we emit a changed signal.
+  /* Keep track of the number of windows open for this app, when it
+   * switches between 0 and 1 we emit an app-added signal.
    */
   usage->window_count++;
   if (usage->initially_seen_sequence == 0)
     usage->initially_seen_sequence = ++self->initially_seen_sequence;
   usage->last_seen = get_time ();
   if (usage->window_count == 1)
-    g_signal_emit (self, signals[CHANGED], 0);
+    g_signal_emit (self, signals[APP_ADDED], 0, app);
+
+  /* Emit window-added after app-added */
+  g_signal_emit (self, signals[WINDOW_ADDED], 0, app, window);
 }
 
 static void
@@ -569,10 +604,12 @@ shell_app_monitor_on_window_removed (MetaWorkspace   *workspace,
   /* Remove before emitting */
   g_hash_table_remove (self->window_to_app, window);
 
+  g_signal_emit (self, signals[WINDOW_REMOVED], 0, app, window);
+
   if (usage->window_count == 0)
     {
       usage->initially_seen_sequence = 0;
-      g_signal_emit (self, signals[CHANGED], 0);
+      g_signal_emit (self, signals[APP_REMOVED], 0);
     }
 }
 
index 491f860149049505e46413756e992e352ef4427c..7858d0a69a235e420ea3b1f6df4692fc670e4aff 100644 (file)
@@ -30,8 +30,6 @@ struct _ShellAppMonitorClass
 {
   GObjectClass parent_class;
   
-  void (*apps_changed)(ShellAppMonitor *menuwrapper,
-                       gpointer         data);
 };
 
 GType shell_app_monitor_get_type (void) G_GNUC_CONST;
index a86d7fd822abf8859480c17064972c7b78f9e5f7..329f8b319debff17788dbb10fccf1c30393b3ba8 100644 (file)
@@ -1,2 +1,4 @@
 VOID:INT,INT,INT
 VOID:OBJECT,INT,INT,INT,INT
+VOID:BOXED
+VOID:BOXED,OBJECT